package com.enums
import groovy.sql.Sql
import com.groovy.DBTypeConvertUtils

public enum DBType {
    MYSQL{
        def getJavaTypeName(type) {
            return "";
        }

        def getInstance(url, username, password) {
            def sql = Sql.newInstance(
                    "jdbc:mysql://" + url, //192.168.16.203:3306/hkjf_dev
                    username,
                    password,
                    "com.mysql.jdbc.Driver");
            return sql;
        }
    }
    , ORACLE{
        def getJavaTypeName(type) {
            return DBTypeConvertUtils.getTypeString(type)
        }

        def getInstance(url, username, password) {
            def sql = Sql.newInstance(
                    "jdbc:oracle:thin:@" + url, //10.140.161.12:1521:orcl
                    username,
                    password,
                    "oracle.jdbc.driver.OracleDriver");
            sql.getConnection().putAt("remarksReporting", "true");//oracle需要这个才能取到remark
            return sql;
        }
    }

    abstract getInstance(url, username, password);

    abstract getJavaTypeName(type);
}
